<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>测试var-let语法结构,var是没有作用域的 let有作用域</title>
		
		
	</head>
	<body>
		
		<button type="button">按钮1</button>
		<button type="button">按钮2</button>
		<button type="button">按钮3</button>
		<script type="text/javascript">
			var a = 100;
			if(a==100){
				var b = "测试发现var是没有作用域限制的.";
			}
			
			console.log(b);
			
			for(var i=0;i<5;i++){
				console.log("我是第"+(i+1)+"次循环");
			}
			
			console.log(i);
			
			if(true){
				
				let aa = 100;
				console.log("我是let属性定义的"+aa);
			}
			
			for(let iii=0;iii<5;iii++){
				console.log("我是第"+(iii+1)+"次循环");
			}
			
			//闭包测试 就是先定义一个函数,之后调用即可
			for(var w=0;w<3;w++){
				(function(w){
					w += 100;
					console.log(w);
				})(w);
			}
			console.log(w);
		</script>
	</body>
</html>
